<template>
	<view class="content">
		<view class="my_wallet">
			<view class="wallet">
				<text><text>￥</text><text>{{wallet}}</text></text>
				<text>可提现余额</text>
			</view>
			<view class="Withdrawal" :class="{'zero':wallet==0}">
				提现
			</view>
		</view>
		<view class="use_methods">
			<view class="use_methods_item" v-for="(item,index) in bookList" :key="index" @click="goDetail(item.id)">
				<view class="use_methods_lf">
					<image :src="item.icon" mode=""></image>
					<text>{{item.bookTitle}}</text>
				</view>
				
				<uni-icons type="arrowright" color="#666666" size="16"></uni-icons>
			</view>
			<view class="use_methods_item" @click="pointsDetails">
				<view class="use_methods_lf">
					<image src="../../static/img/coin.png" mode=""></image>
					<text>收益明细</text>
				</view>
				
				<uni-icons type="arrowright" color="#666666" size="16"></uni-icons>
			</view>
			<view class="use_methods_item" @click="goWithdrawal()">
				<view class="use_methods_lf">
					<image src="../../static/img/Withdrawal.png" mode=""></image>
					<text>提现明细</text>
				</view>
				
				<uni-icons type="arrowright" color="#666666" size="16"></uni-icons>
			</view>
			
		</view>
	</view>
</template>

<script>
	export default{
		data(){
			return {
				bookList:[],
				bookIcon:['../../static/img/Purse.png'],
				wallet:0
			}
		},
		onLoad(data) {
			console.log(data)
			this.wallet=data.data;
			
		},
		onShow() {
			this.bookListFun()
		},
		methods:{
			//提现明细
			goWithdrawal(){
				uni.navigateTo({
				    url: '../mySub/WithdrawalDetails'
				});
			},
			//积分明细
			pointsDetails(){
				uni.navigateTo({
				    url: '../mySub/pointsDetails'
				});
			},
			// 文章列表
			bookListFun(){
				this.$http.get('/api/user/bookList/3').then((data)=>{
					if(data.data.code==200){
						this.bookList=data.data.result||[];
						this.bookList.forEach((a,i)=>{
							if(this.bookIcon[i]){
								a.icon=this.bookIcon[i];
							}
						})
					}else{
						this.bookList=[];
					}
				})
			},
			goDetail(id){
				console.log(id)
				uni.navigateTo({
				    url: '../mySub/bookDetail?id='+id
				});
			}
		}
	}
</script>

<style lang="scss" scoped>
	@import '@/static/css/myWallet.scss'
</style>

